package com.gxitsky.controller;

import com.gxitsky.response.ResponseModel;
import com.gxitsky.service.DoubleColorBallService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author gxing
 * @desc 双色球
 * @date 2022/11/30
 */
@RestController
@RequestMapping("/doubleColor")
public class DoubleColorBallController {

    @Autowired(required = false)
    private DoubleColorBallService doubleColorBallService;

    /**
     * @param count 多少组
     * @desc 生成随机数字
     * @author gxing
     * @date 2022/11/30
     */
    @RequestMapping("/random")
    public ResponseModel<List<String>> random(Integer count) {
        count = ObjectUtils.isNotEmpty(count) ? count : 1;
        List<String> result = doubleColorBallService.random(count);
        return ResponseModel.success(result);
    }

    /**
     * @desc 同步最新
     * @author gxing
     * @date 2022/11/30
     */
    @RequestMapping("/syncLast")
    public ResponseModel<?> syncLast() {
        doubleColorBallService.syncLast();
        return ResponseModel.success();
    }
}
